#!/bin/sh

echo Extracting messages from source files...
echo

(cd ..; python po/tips.py &&
 intltool-extract --type=gettext/glade --update ../Templates.ui &&
 xgettext --keyword=_ --keyword=N_ --output=messages.pot *.c tips ../Templates.ui.h)

echo

if [ "x$1" = "x" ]; then
	echo Updating all .po files...
	echo

	for FILE in *.po; do
		echo -n "Updating '$FILE' translation"
		mv "$FILE" "$FILE.old"
		msgmerge "$FILE.old" ../messages.pot > "$FILE";
		rm "$FILE.old"
	done
else
	FILE="$1"
	if [ ! -f "$FILE" ]; then
	  echo $FILE does not exist!
	  exit 1
	fi
	echo Updating all $1...
	echo

	echo -n "Updating '$FILE' translation"
	mv "$FILE" "$FILE.old"
	msgmerge "$FILE.old" ../messages.pot > "$FILE";
	rm "$FILE.old"
fi
